import request from '../service/service';

/**
 * DAM云小程序-质量检查
 * @param data {Object} 请求参数
 * "project_name":"",// 必填，项目名
 * "page":"0" // 必填，页码，从0开始
 */
export function getQualityInspectionList(data) {
  return request({
    protocol: 'dam/get_quality_list',
    options: data
  });
}

/**
 * DAM云小程序-安全检查
 * @param data {Object} 请求参数
 * "project_name":"",// 必填，项目名
 * "page":"0" // 必填，页码，从0开始
 */
export function getSafetyList(data) {
  return request({
    protocol: 'dam/get_safety_list',
    options: data
  });
}

/**
 * DAM云小程序-安全管理-区域管理获取区域列表数据
 * @param  data {Object}
 */
export function getSecurityAreaList(data) {
  return request({
    protocol: '/bus/security/findPage',
    options: data,
    method: 'get'
  });
}

/**
 * DAM云小程序-安全管理-新增区域管理数据
 * @param  data {Object}
 */
export function addSecurityArea(data) {
  return request({
    protocol: '/bus/security/create',
    options: data,
    method: 'post'
  });
}

/**
 * DAM云小程序-安全管理-删除区域管理数据
 * @param  data {Object}
 */
export function deleteSecurityArea(data) {
  return request({
    protocol: '/bus/security/deleteByIds?ids=' + data.ids,
    method: 'delete'
  });
}

/**
 * 获取打卡人员列表
 * @param  data {Object}
 */
export function getStaffClockByDate(data = {}) {
  let url = '?';
  const len = Object.keys(data).length;
  Object.keys(data).forEach((key, index) => {
    if (!data[key]) return;
    url += `${key}=${data[key]}${index >= len - 1 ? '' : '&'}`;
  });
  return request({
    protocol: '/bus/clock/getStaffClockByDate' + url,
    method: 'post'
  });
}

/**
 * 获取车辆定位数据
 * @param  data {Object}
 */
export function getVehicleLocatorList(data) {
  return request({
    protocol: '/bus/vehicle/getVehicleLocatorList?projectId=' + data.projectId,
    method: 'post'
  });
}

/**
 * 根据定位器id获取当前定位器的历史轨迹
 * @param  data {Object}
 */
export function getHisLocatorById(data) {
  return request({
    protocol: '/bus/vehicle/getHisLocatorById?locatorId=' + data.locatorId,
    method: 'post'
  });
}

/**
 * 获取可绑定的人员列表
 * @param  data {Object}
 */
export function getBindStaffList(data = {}) {
  let url = '?';
  const len = Object.keys(data).length;
  Object.keys(data).forEach((key, index) => {
    if (!data[key]) return;
    url += `${key}=${data[key]}${index >= len - 1 ? '' : '&'}`;
  });
  return request({
    protocol: '/bus/clock/getBindStaffList' + url,
    method: 'post'
  });
}

/**
 * DAM云小程序-安全管理-修改区域管理数据
 * @param  data {Object}
 */
export function editSecurityArea(data) {
  return request({
    protocol: '/bus/security/update',
    options: data,
    method: 'post'
  });
}

/**
 * 根据区域id获取绑定人员列表
 * @param  data {Object}
 */
export function getAreaStaffList(data) {
  return request({
    protocol: '/bus/clock/getAreaStaffList?areaId=' + data.areaId,
    options: data,
    method: 'post'
  });
}

/**
 * 获取小程序打卡信息
 */
export function getAppletStaffClock(data) {
  return request({
    protocol: '/bus/clock/getAppletStaffClock',
    options: data,
    method: 'post',
    hasQuery: true,
  });
}

/**
 * 获取沟槽设备列表
 */
export function getTrenchDeviceList(data) {
  return request({
    protocol: '/bus/monitor/trench/getDeviceList',
    options: data,
    method: 'get',
  });
}

/**
 * 获取沟槽设备的历史记录
 */
export function getTrenchHistoryList(data) {
  return request({
    protocol: '/bus/monitor/trench/getDeviceHistoryList',
    options: data,
    method: 'get',
  });
}

/**
 * 获取沟槽设备一天的数据
 */
export function getTrenchDeviceListByDay(data) {
  return request({
    protocol: '/bus/monitor/trench/getDeviceListByDay',
    options: data,
    method: 'get',
  });
}

/**
 * 设备id获取沟槽设备最新的数据
 */
export function getTrenchNewInfo(data) {
  return request({
    protocol: '/bus/monitor/trench/getNewInfoById',
    options: data,
    method: 'get',
  });
}

/**
 * 获取碾压设备列表
 */
export function getIcccList(data) {
  return request({
    protocol: '/bus/iccc/getList',
    options: data,
    method: 'get',
  });
}

/**
 * 获取碾压设备实时数据
 */
export function getIcccRecive(data) {
  return request({
    protocol: '/bus/iccc/recive',
    options: data,
    method: 'post',
  });
}

/**
 * 根据层数id获取rtk数据
 */
export function getIcccDetectDatas(data) {
  return request({
    protocol: '/bus/iccc/getDetectDatas',
    options: data,
    method: 'get',
  });
}

/**
 * 获取区域层级树形结构
 */
export function getIcccMileageTree(data) {
  return request({
    protocol: '/bus/iccc/getMileageTree',
    options: data,
    method: 'get',
  });
}

/**
 * 登录
 */
export function icccLogin(data) {
  return request({
    protocol: '/bus/iccc/icccLogin',
    options: data,
    method: 'post',
    hasQuery: true
  });
}

/**
 * 获取当前设备最新的信息
 */
export function getPersonLocation(data) {
  return request({
    protocol: '/bus/person/localtion/newData',
    options: data,
    method: 'get',
  });
}

/**
 * 获取设备的历史记录
 */
export function getPersonHistoryLocation(data) {
  return request({
    protocol: '/bus/person/localtion/historyData',
    options: data,
    method: 'get',
  });
}
